package cn.kgc.springcloud.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: mosin
 * @version: v1.0  2023/1/5
 */
@RestController
@RequestMapping("hystrix")
public class HystrixController {

    @RequestMapping("m1")
    @HystrixCommand(fallbackMethod = "method1Fallback")
    public String method1(Integer id){
        if(id<0){
            throw  new  RuntimeException("服务器出现异常");
        }
        return "hystrixService ok";
    }

    public String method1Fallback(Integer id){
        return "网络异常，请稍后再试！！";
    }
    
}
